﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LapvBussiness.Common
{
 public class Utilities
    {
        public static string GetMD5Hash(string input)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            string password = s.ToString();
            return password;
        }
        public static string getFileExtension(string filename)
        {
            int j = filename.LastIndexOf(".");
            if (j <= 0)
                return "";
            return (filename.Substring(j + 1)).ToLower();
        }
        public static string UpperCaseFirst(string s)
        {
            StringBuilder sb = new StringBuilder();
            string[] array = s.Split(' ');

            for (int i = 0; i < array.Length; i++)
            {
                string firstLetter = array[i].Substring(0, 1);
                string secondPart = array[i].Substring(1);
                sb.Append(firstLetter.ToUpper() + secondPart + " ");
            }

            return sb.ToString().Remove(sb.Length - 1);
        }
    }
}
